package com.whw.fy.service.impl;

import com.whw.fy.entity.Message;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.whw.fy.mapper.PlanSummarizeTableMapper;
import com.whw.fy.entity.PlanSummarizeTable;
import com.whw.fy.service.PlanSummarizeTableService;

import java.text.ParseException;
import java.text.SimpleDateFormat;

@Service
public class PlanSummarizeTableServiceImpl implements PlanSummarizeTableService{

    @Resource
    private PlanSummarizeTableMapper planSummarizeTableMapper;

    @Override
    public Message deleteByPrimaryKey(Integer planSummarizeTableId) {
        return planSummarizeTableMapper.deleteByPrimaryKey(planSummarizeTableId)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message insert(PlanSummarizeTable record) {
        return planSummarizeTableMapper.insert(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message insertSelective(PlanSummarizeTable planSummarizeTable) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        if (planSummarizeTable.getPlanSummarizeTableStarttimeToString()!=null)
            planSummarizeTable.setPlanSummarizeTableStarttime(simpleDateFormat.parse(planSummarizeTable.getPlanSummarizeTableStarttimeToString()));
        if (planSummarizeTable.getPlanSummarizeTableFinishtimeToString()!=null)
            planSummarizeTable.setPlanSummarizeTableFinishtime(simpleDateFormat.parse(planSummarizeTable.getPlanSummarizeTableFinishtimeToString()));
        return planSummarizeTableMapper.insertSelective(planSummarizeTable)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message selectByPrimaryKey(Integer planSummarizeTableId) {
        return Message.success(null).add(planSummarizeTableMapper.selectByPrimaryKey(planSummarizeTableId));
    }

    @Override
    public Message updateByPrimaryKeySelective(PlanSummarizeTable record) {
        return planSummarizeTableMapper.updateByPrimaryKeySelective(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message updateByPrimaryKey(PlanSummarizeTable record) {
        return planSummarizeTableMapper.updateByPrimaryKey(record)>0?Message.success(null):Message.fail(null);
    }

    @Override
    public Message selectAll() {
        return Message.success(null).add(planSummarizeTableMapper.selectAll());
    }

}
